<template>
  <base-breadcrumb :title="$route.meta.title">
    <!-- QC活动成果资料评审 -->
    <div id="base-breadcrumb" style="position: relative; overflow: hidden">
      <!-- 搜索 -->
      <searchData :searchData="searchArr" @search="search"></searchData>
      <!-- 表格 -->
      <a-card :bordered="false">
        <!-- <title-name title="QC活动成果评审"></title-name> -->
        <!-- 表格 -->
        <list-table
          ref="table"
          tableLayout="fixed"
          size="default"
          :columns="columns"
          :request="loadData"
          :isShowCountBar="false"
        >
          <a-button slot="prefix" v-btnPermission="[
                      {
                        ident: 'prma_seex',
                        code: 'seex_qm_043_rev_01'
                      },
                      {
                        ident: 'prma_buco',
                        code: 'buco_qm_043_rev_01'
                      }
              ]" icon="plus" type="primary" @click="handleManage(1)"
            >发起评审</a-button
          >
          <template slot="actions" slot-scope="text, record">
            <MoreButton>
            <a v-btnPermission="[
                      {
                        ident: 'prma_seex',
                        code: 'seex_qm_043_loo_02'
                      },
                      {
                        ident: 'prma_buco',
                        code: 'buco_qm_043_loo_02'
                      }
              ]" @click="handleManage(0, record)">查看</a>
            <template v-if="record.isOperation">
              <a v-btnPermission="[
                      {
                        ident: 'prma_seex',
                        code: 'seex_qm_043_dpo_03'
                      },
                      {
                        ident: 'prma_buco',
                        code: 'buco_qm_043_dpo_03'
                      }
              ]" @click="handleManage(2, record)">扣分</a>

              <a v-btnPermission="[
                      {
                        ident: 'prma_seex',
                        code: 'seex_qm_043_rer_04'
                      },
                      {
                        ident: 'prma_buco',
                        code: 'buco_qm_043_rer_04'
                      }
              ]" @click="handleManage(3, record)">发布成果</a>
            </template>
            </MoreButton>
          </template>
        </list-table>
      </a-card>
    </div>
  </base-breadcrumb>
</template>

<script>
import { qcActivityAchievementReview } from '@/api/quality/quality' // api
import SelectCompanyAndSubCompany from '@/components/Select/SelectCompanyAndSubCompany'
import BasePage from '@/views/basePage'
const searchArr = [
  // 搜索框
  {
    name: '评审组织单位',
    type: SelectCompanyAndSubCompany,
    valueKey: 'reviewUnitId'
  },
  {
    name: '活动开展年度',
    type: 'yearRange',
    value: 'year',
    attr: {
      rangeFormat: ['startYear', 'endYear'],
      placeholder: ['开始时间', '截止时间']
    }
  },
  {
    name: '评审阶段',
    type: 'BaseInput',
    valueKey: 'reviewStage',
    addonBefore: '第',
    addonAfter: '次'
  }
]
const columns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  },
  {
    title: '评审组织单位',
    ellipsis: true,
    dataIndex: 'reviewUnitName'
  },
  {
    title: '年度时间',
    ellipsis: true,
    dataIndex: 'yearDate'
  },
  {
    title: '评审阶段',
    ellipsis: true,
    dataIndex: 'reviewStage'
  },
  {
    title: '发起人',
    ellipsis: true,
    dataIndex: 'launchEmployeeName'
  },
  {
    title: '发起时间',
    ellipsis: true,
    dataIndex: 'launchTime'
  },
  {
    title: '操作',
    dataIndex: 'actions',
    width: '180px',
    align: 'center',
    scopedSlots: { customRender: 'actions' }
  }
]
export default {
  name: 'a' + Date.now(),
  extends: new BasePage(),
  data() {
    this.columns = columns
    this.searchArr = searchArr
    return {
      queryParam: {}, // 查询参数
      removeApi: qcActivityAchievementReview,
      // 加载数据方法 必须为 Promise 对象
      loadData: (parameter) => {
        this.loadCount++
        const requestParameters = Object.assign({}, parameter, { query: this.queryParam })
        return qcActivityAchievementReview.getListByQuery(requestParameters).then((res) => {
          return res
        })
      },
      editModel: 0,
      api: qcActivityAchievementReview, // 汇总api
      loadCount: 0, // 汇总加载控件
      form: {},
      exportLoading: {
        0: false,
        1: false
      } // 导出loading
    }
  },
  methods: {
    // 搜索
    search(value) {
      value && (this.queryParam = value)
      this.$refs.table.refresh(true)
    },
    // 操作栏
    handleManage(type, record) {
      this.editModel = type
      let query = {
        editModel: type
      }
      if (record && record.id) {
        query.id = record.id
      }
      this.$router.push({
        name: 'QCActivityResultEdit',
        query
      })
    }
  }
}
</script>

<style lang="less" scoped>
/deep/ .ant-select-tree-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 190px;
  display: inline-block;
  vertical-align: bottom; // 错位问题解决
}
</style>
